import React, { Component, Suspense } from 'react'
import { Switch, Route ,Redirect} from 'react-router-dom'
import router from './router/index'
import { Layout } from 'antd'
import Header from './component/Header'
import Footer from './component/Footer'
import './static/css/common.css'

export default class App extends Component {
  render() {
    return (
      <div>
        <Layout className='page'>
          <Header />
          <Layout.Content>
            <div
              className='wrap'
            >
              <Suspense fallback="loading...">
              <Switch>
                {router.map((item, index) => {
                  return (
                    <Route
                      key={index}
                      path={item.path}
                      render={props => {
                        console.log(props) // 接收路由传过来的参数 比如 history等
                        return item.render(props)
                      }}
                    />
                  )
                })}
                <Redirect to={'/indexpage'}></Redirect>
                {/* 如果Indexpage 的路径 为 / 那么跳转路由没有反应*/}
              </Switch>
              </Suspense>
            </div>
          </Layout.Content>
          <Footer />
        </Layout>
      </div>
    )
  }
}
